# Maintainer: Levente Polyak <anthraxx[at]archlinux[dot]org>
# Contributor: Bartłomiej Piotrowski <bpiotrowski@archlinux.org>

pkgbase=libstrophe
pkgname=('libstrophe' 'libstrophe-doc')
pkgver=0.12.2
pkgrel=2
epoch=1
pkgdesc='Simple, lightweight C library for writing XMPP clients'
url='http://strophe.im/libstrophe/'
arch=('loong64' 'x86_64')
license=('GPL3' 'MIT')
depends=('glibc' 'openssl' 'expat')
makedepends=('doxygen')
checkdepends=('check')
source=(https://github.com/strophe/libstrophe/archive/${pkgver}/${pkgname}-${pkgver}.tar.gz)
sha512sums=('2eb2ab98a7335c18ae964bb3b565a6dc8ddcbf2b1503288a0080ceb8c2e7f5b39bbefca0cfd9962e103a8410f4adeffc92618b83978405d598fd5bb886ad67b6')
b2sums=('2bcd2d5f43b0b402059bb85c661a54a642f745ae194d0451bf5de1973667a3f747358e9095bd1d463924c62994d456e60573464c5191deaae89581abda200b73')

prepare() {
  cd ${pkgbase}-${pkgver}
  autoreconf -fiv
}

build() {
  cd ${pkgbase}-${pkgver}
  ./configure \
    --prefix=/usr
  make
  doxygen
}

check() {
  make -C ${pkgbase}-${pkgver} check
}

package_libstrophe() {
  depends+=('libexpat.so')
  provides=('libstrophe.so')
  cd ${pkgbase}-${pkgver}
  make DESTDIR="${pkgdir}" install
  install -Dm 644 MIT-LICENSE.txt "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE-MIT"
}

package_libstrophe-doc() {
  pkgdesc+=' (documentation and samples)'
  depends=()
  options=('!strip')
  optdepends=('libstrophe')
  cd ${pkgbase}-${pkgver}
  install -Dm 644 docs/html/* -t "${pkgdir}/usr/share/doc/${pkgname}/html"
  install -Dm 644 examples/{README.md,*.c} -t "${pkgdir}/usr/share/doc/${pkgname}/examples"
  install -Dm 644 MIT-LICENSE.txt -t "${pkgdir}/usr/share/licenses/${pkgname}"
}

# vim: ts=2 sw=2 et:
